package com.tianbing.adlottery.controller.user;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.tianbing.adlottery.helper.SkinUtils;
import com.tianbing.adlottery.util.UserSession;

public class LoginAutoInterceptor extends HandlerInterceptorAdapter {
	static Logger logger = Logger.getLogger(LoginAutoInterceptor.class);

	private SkinUtils skinUtils;

	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
		UserSession auth = skinUtils.getUserAuthorization(request, response);
		if (auth != null) {
			auth.setCheckLoginAuto(true);
		}
		return true;
	}

	public void setSkinUtils(SkinUtils skinUtils) {
		this.skinUtils = skinUtils;
	}

	public static void setLogger(Logger logger) {
		LoginAutoInterceptor.logger = logger;
	}

}
